package ar.uba.fi.tp2Unit.displayers.xml;

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class TestSuiteXML implements XMLSerializable {
	
	private List<TestSuiteXML> testSuites;
	private List<TestCaseXML> testCases;
	private String name;
	private String errors;
	private String failures;
	private String tests;
	private String time;
	

	public TestSuiteXML (){
		name = "";
		time = "0";
		errors = "0";
		failures = "0";
		tests = "0";
		testSuites = new ArrayList<TestSuiteXML>();
		testCases = new ArrayList<TestCaseXML>();
	}
	
	public List<TestSuiteXML> getTestSuites() {
		return testSuites;
	}
	public void setTestSuites(List<TestSuiteXML> testSuites) {
		this.testSuites = testSuites;
	}
	public List<TestCaseXML> getTestCases() {
		return testCases;
	}
	public void setTestCases(List<TestCaseXML> testCases) {
		this.testCases = testCases;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getErrors() {
		return errors;
	}
	public void setErrors(String errors) {
		this.errors = errors;
	}
	public String getFailures() {
		return failures;
	}
	public void setFailures(String failures) {
		this.failures = failures;
	}
	public String getTests() {
		return tests;
	}
	public void setTests(String tests) {
		this.tests = tests;
	}
	public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}

	public Node serializeXml(Document doc) {
		Element element = doc.createElement("testsuite");
		element.setAttribute("name", this.getName());
		element.setAttribute("errors", this.getErrors());
		element.setAttribute("failures", this.getFailures());
		element.setAttribute("tests", this.getTests());
		element.setAttribute("time", this.getTime());
		for (TestSuiteXML testSuite : this.getTestSuites()) {
			element.appendChild(testSuite.serializeXml(doc));
		}
		for (TestCaseXML testCase : this.getTestCases()) {
			element.appendChild(testCase.serializeXml(doc));
		}
		return element;
	}
	
}
